package com.brucekong.slm.controller.console;

import com.brucekong.slm.common.PageResult;
import com.brucekong.slm.model.console.PrograssDomain;
import com.brucekong.slm.service.console.PrograssService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 控制台控制类
 */
@RestController
@RequestMapping("/console")
@Slf4j
@Api(value = "控制台模块", tags = "控制台模块")
public class PrograssController {

    private PageResult pageResult = new PageResult();

    @Autowired
    private PrograssService prograssService;

    /**
     * 项目进展
     *
     * @return pageResult 获取项目进展列表
     */
    @GetMapping("/prograss")
    @SuppressWarnings("unchecked")
    @ApiOperation(value = "项目进展", notes = "获取项目进展列表", code = 200, produces = "application/json", responseContainer = "List", response = PageResult.class)
    public PageResult getPrograss(@RequestParam(name = "page", required = false, defaultValue = "1") int page,
                                  @RequestParam(name = "limit", required = false, defaultValue = "10") int limit) {
        log.info("/console/prograss");
        PageInfo<PrograssDomain> prograssDomainList = prograssService.getPrograss(page, limit);

        pageResult.setCode(0);
        pageResult.setMsg(null);
        pageResult.setSuccess(true);
        pageResult.setCount(prograssDomainList.getTotal());
        pageResult.setData(prograssDomainList.getList());
        return pageResult;
    }

}